
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_pleasure_video/constant/color.dart';
import 'package:flutter_pleasure_video/data/model/yck_rule_model.dart';
import 'package:flutter_pleasure_video/widget/diglog/debug_dialog.dart';

import 'common_dialog.dart';
import 'import_source_dialog.dart';

class AppDialog{

  //debug-提示面板的dialog
  static showDebugAlertTextDialog(BuildContext context,
      String alertText,
      {Function()? onClickListener,
        Function()? onExitListener,
        bool barrierDismissible = true}) {
    showDialog(
        context: context,
        barrierDismissible: barrierDismissible,
        builder: (context) {
          return WillPopScope(
              onWillPop: () async => barrierDismissible, //用来屏蔽安卓返回键关弹窗
              child: Dialog(
                backgroundColor: AppColor.transparent,
                elevation:0,
                child: DebugDialog(alertText,onClickListener:onClickListener,onExitListener:onExitListener),
              ));
        });
  }

  //导入资源的dialog
  static showImportSourceDialog(BuildContext context,List<YckRuleModel>? modelList,
      {Function()? onExitListener,bool barrierDismissible = false}){
    if(modelList==null){
      return;
    }
    showDialog(
        context: context,
        barrierDismissible: barrierDismissible,
        builder: (context) {
          return WillPopScope(
              onWillPop: () async => barrierDismissible, //用来屏蔽安卓返回键关弹窗
              child: Dialog(
                backgroundColor: AppColor.white,
                elevation:0,
                child: ImportSourceDialog(modelList,onExitListener:onExitListener),
              ));
        });
  }


  //普通的弹窗
  static showCommonDialog(BuildContext context,
      {AppDialogButton? confirm,
        AppDialogButton? cancel,
        List<AppDialogButton>? buttonList,
        String? title,
        String? info,
        double? progress,
        Widget? customizeWidget,
        String? circleImageUrl,
        String? topImageUrl,
        bool barrierDismissible = true}) {
    showDialog(
        context: context,
        barrierDismissible: barrierDismissible,
        builder: (context) {
          return WillPopScope(
              onWillPop: () async => barrierDismissible, //用来屏蔽安卓返回键关弹窗
              child: Dialog(
                child: CommonDialog(
                    confirm: confirm,
                    cancel: cancel,
                    buttonList: buttonList,
                    title: title,
                    info: info,
                    customizeWidget: customizeWidget,
                    circleImageUrl: circleImageUrl,
                    topImageUrl: topImageUrl),
              ));
        });
  }
}